<template>
  <div>
    <transition name="slide-fade">
      <div :style="{top: isArr + '%' }" class="toast" v-if="visible">
        <i class="iconfont" :class="isIcon"></i>
        <div>
          {{ message }}
        </div>
      </div>
    </transition>
  </div>
</template>

<script>
export default {
  data() {
    return {
      visible: false,
      message: "",
      isArr: "",
      isIcon: "",
    };
  },
};
</script>

<style scoped>
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px;
  color: #fff;
  font-size: 14px;
  line-height: 20px;
  background-color: rgba(0, 0, 0, 0.7);
  border-radius: 8px;
  transform: translate3d(-50%, -50%, 0);
}

.slide-fade-enter,
.slide-fade-leave-to {
  margin-top: -30px;
  opacity: 0;
}

.slide-fade-enter-active,
.slide-fade-leave-active {
  transition: all 0.3s ease;
}

.slide-fade-enter-to,
.slide-fade-leave {
  margin-top: 0px;
  opacity: 1;
}

i {
  font-size: 30px;
}

.toast div {
  margin-top: 10px;
}
</style>